package cn.shopping.common.controller;

import cn.shopping.common.util.CommonUtils;
import cn.shopping.common.vo.ResponseVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;

import javax.servlet.http.HttpServletRequest;

/**
 * 描述:Controller的父类.
 *  <pre>
 *       1.统一的异常处理
 *  </pre>
 * @author Zhanggq
 * @date 2019/4/4 10:09
 */
public abstract class BaseController {

    private static final Logger logger= LoggerFactory.getLogger(BaseController.class);

    @ExceptionHandler
    public ResponseVO<?> exceptionHandler(HttpServletRequest request, Exception e)
    {
        logger.error("服务调用异常",e);
        ResponseVO<?> responseVO= CommonUtils.errorResponseVO(e);
        return responseVO;
    }
}
